package com.zhou.listener.utils;

import com.zhou.listener.library.ListenerManager;
import com.zhou.listener.library.baselistener.IBaseFileDownloadListener;
import com.zhou.listener.library.listener.IFileDownloaderDownloadListener;
import com.zhou.listener.library.utils.IKey;

import java.util.List;

public class AdapterUtils {
    public static void clearPreListener(List<IKey> keys){
        if(keys==null){
            return;
        }
        for(int i=0;i<keys.size();i++){
            IBaseFileDownloadListener listener = ListenerManager.getInstance().getListener(keys.get(i));
            if(listener!=null){
                listener.deleteFileDownloaderDownloadListener();
            }
        }
        keys.clear();
    }

    public static void updateListener(List<IKey> keys, IFileDownloaderDownloadListener l){
        for(int i=0;i<keys.size();i++){
            if(ListenerManager.getInstance().containsKey(keys.get(i))){
                IBaseFileDownloadListener listener=ListenerManager.getInstance().getListener(keys.get(i));
                listener.updateFileDownloaderDownloadListener(l);
            }
        }

    }
}
